package gui;

import javax.swing.*;

import java.awt.*;

import static java.awt.GridBagConstraints.*;
import javax.swing.JButton;

import application.GameManager;

import listeners.IceAgeButtonPressed;
import listeners.OranButtonPressed;
import listeners.PredButtonListener;

public class StartGamePanel extends JPanel{

	private GameManager _GameManager;
	private Image _backround;
	
	public StartGamePanel(GameManager manager){
		super(new GridBagLayout());
		this._backround = new ImageIcon("StartFrameBackround.png").getImage();
		this._GameManager = manager;
		GridBagConstraints tPorto = new GridBagConstraints();
		tPorto.insets = new Insets(3,3,3,3);
		
		GridBagConstraints tButton = (GridBagConstraints)tPorto.clone();
		tButton.gridheight = 3;tButton.gridwidth = 3;
		tButton.fill = NONE;
		tButton.anchor = FIRST_LINE_END;
		
		ImageIcon tPredBack = new ImageIcon("cobra-snake-plastic copy.png");
		JButton tPredSnake = new JButton("Predetor",tPredBack);
		tPredSnake.addActionListener(new PredButtonListener(this._GameManager));
		//tPredSnake.setIcon(TPredBack);
		tPredSnake.setVerticalTextPosition(SwingConstants.BOTTOM);
		tPredSnake.setHorizontalTextPosition(SwingConstants.CENTER);
		GridBagConstraints tPredButton = (GridBagConstraints) tButton.clone();
		tPredSnake.setToolTipText("Start Game as Predetor!");
		tPredButton.gridx = 1;tPredButton.gridy = 1; 
		add(tPredSnake,tPredButton);
		
		ImageIcon tOrenBack = new ImageIcon("sgreen copy.png");
		JButton tOrnamentalButton = new JButton("Ornamental",tOrenBack);
		tOrnamentalButton.addActionListener(new OranButtonPressed(this._GameManager));
		tOrnamentalButton.setVerticalTextPosition(SwingConstants.BOTTOM);
		tOrnamentalButton.setHorizontalTextPosition(SwingConstants.CENTER);
		tOrnamentalButton.setToolTipText("Start Game as Oranmental!");
		GridBagConstraints tOranButtCons = (GridBagConstraints) tButton.clone();
		tOranButtCons.gridx = 4; tOranButtCons.gridy = 1;
		add(tOrnamentalButton,tOranButtCons);
		
		ImageIcon tIceAgeButtonBack = new ImageIcon("resSnakeButton.png");
		JButton tIceAgeButton = new JButton("IceAgeSnake",tIceAgeButtonBack);
		tIceAgeButton.addActionListener(new IceAgeButtonPressed(this._GameManager));
		tIceAgeButton.setVerticalTextPosition(SwingConstants.BOTTOM);
		tIceAgeButton.setHorizontalTextPosition(SwingConstants.CENTER);
		tIceAgeButton.setToolTipText("Start game as Ice Age Snake!");
		GridBagConstraints tIceAgeCons = (GridBagConstraints) tButton.clone();
		tIceAgeCons.gridx = 7;tIceAgeCons.gridy = 1;
		add(tIceAgeButton,tIceAgeCons);
		
		JButton tAdultVersionButton = new JButton("18+ version.");
		tAdultVersionButton.addActionListener(new AdultButtonPressed(this._GameManager));
		tAdultVersionButton.setToolTipText("Start game in 18+ ver.");
		GridBagConstraints tAdultButtCons = (GridBagConstraints) tButton.clone();
		tAdultButtCons.gridx = 7;tAdultButtCons.gridy = 5;
		add(tAdultVersionButton,tAdultButtCons);
	}
	
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		g.drawImage(this._backround, 0, 0,getWidth(),getHeight(), this);
	}
}
